<template>
  <div class="dialog-content">
<!--    {{ formData }}-->
<!--    <AudioPlayer />-->
    <component
      v-if="view"
      :is="view"
      :resourceUrl="resourceUrl"
    />
    <p v-else>暂不支持此类资源</p>
  </div>
</template>

<script>
import ImagePlayer from '@/views/components/ResourcePlayer/ImagePlayer'
import VideoPlayer from '@/views/components/ResourcePlayer/VideoPlayer'
import PdfPlayer from '@/views/components/ResourcePlayer/PdfPlayer'
import ModelPlayer from '@/views/components/ResourcePlayer/ModelPlayer'
import AudioPlayer from '@/views/components/ResourcePlayer/AudioPlayer'
import { mapGetters } from 'vuex'
export default {
  name: 'ResourcePlayer',
  components: {
    ImagePlayer,
    PdfPlayer,
    ModelPlayer,
    AudioPlayer,
    VideoPlayer
  },
  mixins: [],
  props: {
    formData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      view: '',
      resourceUrl: ''
    }
  },
  computed: {
    ...mapGetters(['fileServer'])
  },
  watch: {},
  created() {
    // 图片，视频，文档，模型，音频
    const type = +this.formData.type
    const views = ['PdfPlayer', 'ImagePlayer', 'VideoPlayer', 'AudioPlayer', 'ModelPlayer']
    this.view = views[type]
    this.resourceUrl = this.fileServer + (this.formData.previewFile || this.formData.file.url)

  },
  mounted() {
  },
  methods: {}
}
</script>

<style scoped lang="scss">

</style>
